home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD ROM Paradise Collection 4
/
CD ROM Paradise Collection 4 1995 Nov.iso
/
os2
/
adaptor.zip
/
ADAPT.ZIP
/
adaptor
/
examples
/
fakul
/
fakul2.f
< prev
next >
Wrap
Text File
|
1993-03-23
|
990b
|
41 lines
Program fakul
CC
CC Fakultaetsprogram, FORTRAN 90 Version
CC
c implicit NONE
integer max
integer feld(:), carry(:)
integer I,K,N
integer length
integer s, lastval
print *, 'Input value N !'
read *, N
print *, 'Input upper limit for size !'
read *, max
allocate (feld(1:max), carry(1:max))
feld = 0
carry = 0
feld(1)=1
length = 1
do K=N,1,-1
feld(1:length) = (feld(1:length) + carry(1:length))*K
carry(1:length) = feld(1:length) / 65536
feld(1:length) = feld(1:length) - carry(1:length) * 65536
if (carry(length) .NE. 0) length = length + 1
carry (2:length) = carry (1:length-1)
carry (1) = 0
end do
lastval = feld(length)
s = sum (feld(1:length))
print *, 'Size = ', length
print *, 'Lastval = ', lastval
print *, 'Control sum = ', s
deallocate (carry, feld)
end